package StringBuilder.fourWork;

import java.util.ArrayList;
import java.util.Scanner;

public class Four {
    public static void main(String[] args) {
        ArrayList<Stu> aL=new ArrayList<>();
        Stu st1=inSert();
        Stu st2=inSert();
        Stu st3=inSert();
        Stu st4=inSert();
        Stu st5=inSert();
        aL.add(st1);
        aL.add(st2);
        aL.add(st3);
        aL.add(st4);
        aL.add(st5);
        for (int i = 0; i < aL.size(); i++) {
            Stu st=aL.get(i);
            System.out.println(st.getName()+" "+st.getAge());
        }
        for (int i = 0; i < aL.size(); i++) {
            if ("张无".equals(aL.get(i).getName())){
                aL.get(i).setName("张五");
                break ;
            }
        }
        for (int i = 0; i < aL.size(); i++) {
            Stu ss=aL.get(i);
            System.out.println(ss.getName()+"  "+ss.getAge());
        }
    }

    private static Stu inSert() {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入姓名：");
        String name=sc.next();
        System.out.println("请输入年龄：");
        int age=sc.nextInt();
        return new Stu(name,age);
    }
}
class Stu{
    private String name;
    private int age;

    public Stu() {
    }

    public Stu(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
